﻿using Microsoft.Extensions.Configuration;
using Microsoft.Extensions.DependencyInjection;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using UwinEducation.Application.Common.Interfaces;
using UwinEducation.Application.Services;
using System.Reflection;
using Microsoft.AspNetCore.Http;
using UwinEducation.Shared;
using UwinEducation.Infrastructure.Persistence;
using UwinEducation.Infrastructure;
using UwinEducation.Shared.Services;
using UwinEducation.Application.Common.Interfaces.Orders;
using UwinEducation.Application.Services.Orders;
using UwinEducation.Domain.IRepositories;
using UwinEducation.Infrastructure.Repositories;
using UwinEducation.Application.Services.Descriptions;

namespace UwinEducation.Application
{
    public static class DependencyInjection
    {
        public static IServiceCollection AddApplicationLayer(this IServiceCollection services, IConfiguration configuration)
        {
            //// 注册 MediatR
            //services.AddMediatR(cfg =>
            //{
            //    cfg.RegisterServicesFromAssembly(Assembly.GetExecutingAssembly());
            //});

            //// 注册 FluentValidation
            //services.AddValidatorsFromAssembly(Assembly.GetExecutingAssembly());

            // 注册服务
            services.AddScoped<ICacheService, RedisCacheService>();
            services.AddScoped<IPasswordHasher, PasswordHasher>();
            services.AddScoped<IAuthService, AuthService>();
            services.AddScoped<IUserService, UserService>();
            services.AddScoped<ICurrentUserService, CurrentUserService>();
            services.AddScoped<IPermissionService, PermissionService>();
            services.AddScoped<IRoleService, RoleService>();
            services.AddScoped<IStudentService, StudentService>();
            services.AddScoped<ITeacherService, TeacherService>();
            services.AddScoped<IClassroomService, ClassroomService>();
            services.AddScoped<ICourseService, CourseService>();
            services.AddScoped<ITermService, TermService>();

            services.AddScoped<ITeacherScheduleService, TeacherScheduleService>();
            services.AddScoped<ITeacherAvailabilityService, TeacherAvailabilityService>();
            services.AddScoped<ITeacherVacationService, TeacherVacationService>();
            services.AddScoped<IStudentScheduleService, StudentScheduleService>();
            services.AddScoped<IStudentPaymentService, StudentPaymentService>();

            services.AddScoped<IOrderService, OrderService>();
            services.AddScoped<IOrderDetailService, OrderDetailService>();
            services.AddScoped<IStudentScheduleDetailsService, StudentScheduleDetailsService>();
            services.AddScoped<IOrderDiscountService, OrderDiscountService>();
            services.AddScoped<IOrderPaymentService, OrderPaymentService>();
            services.AddScoped<IAppointmentService, AppointmentService>();
            services.AddScoped<ISystemConfigService, SystemConfigService>();
            services.AddScoped<IDescriptionService, DescriptionService>();

            // 注册基础设施服务
            services.AddInfrastructureServices(configuration);

            return services;
        }


    }
}
